home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: netcom.com!marnold
- From: marnold@netcom.com (Matt Arnold)
- Subject: Re: STL destroy() and warnings
- Message-ID: <marnoldDox3tn.C6u@netcom.com>
- Organization: NETCOM On-line Communication Services (408 261-4700 guest)
- References: <J.Hamer-2703960916160001@john-ha.cs.auckland.ac.nz>
- Date: Wed, 27 Mar 1996 08:34:35 GMT
- Sender: marnold@netcom18.netcom.com
-
- J.Hamer@cs.auckland.ac.nz (John Hamer) writes:
-
- >These questions relate to the October 31, 1995 release of the
- >Hewlett-Packard implementation of STL, running under Borland C++ 4.5.
-
- >1. This STL implementation does not appear to be able to cope directly
- >with a container of pointers. The template for destroy() in defalloc.h
- >attempts to call pointer->~T() where T is a pointer to a pointer type, and
- >a compiler error results. What are the recommended work-arounds?
-
- You must write your own destroy() function for your specific types. Most
- C++ compilers will not compile an explicit destructor call for a pointer
- type.
-
- For example, if you have some container of Foo pointers, you need to
- provide this somwhere...
-
- void destroy(Foo**) { }
-
- This *is* the intended work-around in the current version of STL for
- compilers that cannot correctly instantiate the template...
-
- template <class T>
- void destroy(T* pointer) { pointer->~T(); }
-
- ...for any type T (which doesn't really do anything if T is a pointer
- anyway).
-
- STL uses this work-around itself. See "defalloc.h" where it defines a
- bunch of "do-nothing" destroy() functions for as many pointers to
- integral types (such as ints, chars and floats) that the authors thought
- would be useful.
-
- I believe Borland C++ 5.0 is one of the compiler's out now that will
- correctly instantiate the destroy() template for any type T. With 4.5,
- you will need the manual work-around.
-
- >2. I get a large number of compiler warnings about ``Conversion will lose
- >significant digits'' when compiling with the large memory model. This
- >looks to be more of a nuisance than a problem; are there any patches
- >available to make the compiler shut up?
-
- Turn off that warning (see Options|Project|Messages|Portability). Or, go
- through the STL code and insert the appropriate casts to show the compiler
- that the code really knows what its doing.
-
- In the world of segmented addresses, you get this warning when you try to
- add more than a 16-bit quantity to a pointer (or index into an array with
- more than a 16-bit quantity). I believe the STL code does quite a bit of
- this.
-
- If you are just getting into STL, I highly recommend the book "The C++
- Programmer's Guide to The Standard Template Library" from IDG books. It
- is very complete.
-
- Regards,
- -------------------------------------------------------------------------
- Matt Arnold | | ||| | |||| | | | || ||
- marnold@netcom.com | | ||| | |||| | | | || ||
- Boston, MA | 0 | ||| | |||| | | | || ||
- 617.389.7384 (h) 617.576.2760 (w) | | ||| | |||| | | | || ||
- C++, MIDI, Win32/95 developer | | ||| 4 3 1 0 8 3 || ||
- -------------------------------------------------------------------------
-